package com.yanxibao.mapper;

import com.yanxibao.bean.Comments;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yanxibao.dto.CommentsUserDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author kongke
* @description 针对表【yxb_comments(评论表)】的数据库操作Mapper
* @createDate 2023-11-19 20:12:44
* @Entity com.yanxibao.bean.Comments
*/
@Mapper
public interface CommentsMapper extends BaseMapper<Comments> {

    /*
    查询评论信息以及用户信息
     */
    @Select("SELECT c.`id`,c.`blog_id`,c.`contents`,c.`likes`,c.`publish_time`,u.`user_id`,u.`user_name`,u.`user_specialized`,u.`user_photo` FROM yxb_comments c, yxb_user u WHERE c.`user_id` = u.`user_id` and c.`blog_id` = #{blogId} ORDER BY c.`likes` DESC")
    List<CommentsUserDTO> selectCommentsUser(Integer blogId);


}




